<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@taglib uri="/typeUtil"  prefix="typeUtil"%>
    <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>订单详情</title>
	<link rel="stylesheet" href="css/style.css">
</head>
<body>
			
			<div class="row">
				<div class="col-md-12">
					<div class="section-title text-center">
						<!--  <h2>订单详情</h2> -->
					</div>
				</div>
			</div>
			<div class="row">
				<div class="feature-full-1col">
					<div class="image" style="background-image: url(/hotel/upload/${room.pic });">
						<div class="descrip text-center">
							<p><small>订单状态</small><span>${condi==0?'未支付':(condi==1?'已支付':'已失效') }</span></p>
						</div>
					</div>
					<div class="desc">
						<h3>订单id:${orderId }</h3>
						<input type='hidden' id='orderId' value='${orderId }'>
						<input type='hidden' id='password' value='${password }'>
						<p>房间名称：${room.name}</p>
						<p>入住日期：${inDate }~${outDate } </p>
						<p>操作密码：${password }</p>
						<p>房型:${typeUtil:getTypeName(room.typeId)}</p>
						<p>楼层：${room.floor }</p>
						<p>联系电话:${phone}</p>
						<p>总金额:${price }</p>
						<c:if test="${condi==0}">
							<button id="pay" class="btn btn-primary btn-luxe-primary">确认付款<i class="ti-angle-right"></i></button> 
							<button id="cancel" class="btn btn-primary btn-luxe-primary">取消订单<i class="ti-angle-right"></i></button>
						</c:if> 
						<c:if test="${condi==1}">
							<button id="refund" class="btn btn-primary btn-luxe-primary">请求退款<i class="ti-angle-right"></i></button>
						</c:if>
						<a class="btn btn-primary btn-luxe-primary" href='/hotel/visitor/roomList'>返回首页<i class="ti-angle-right"></i></a>
					</div>
				</div>

			</div>
	
	
</body>
<script type="text/javascript" src="/hotel/js/jquery.min.js"></script>
<script type="text/javascript">
<c:if test="${condi==0}">
$("#cancel").click(function(){
	if(!confirm('您确定要取消订单吗'))
		return 
	$.post("/hotel/reserve/cancelRoom",{id:$('#orderId').val(),'password':$('#password').val()},function(str){
		var res=eval('(' +str + ')')
		if(res.code!=0){
			alert(res.message)
			return;
		}else{
			res=res.object
			window.location.href="/hotel/visitor/roomList"
		}
	})
})
	$('#pay').click(function(){
		if(!confirm('您确定要付款吗'))
			return 
		$.post("/hotel/reserve/payReserve",{id:$('#orderId').val()},function(str){
			var res=eval('(' +str + ')')
			if(res.code!=0){
				alert(res.message)
				return;
			}else{
				res=res.object
				window.location.href="/hotel/reserve/getReserve?id="+$('#orderId').val()
			}
		})
	})
</c:if>
<c:if test="${condi==1}">
$('#refund').click(function(){
if(!confirm('您确定要发起退款吗'))
	return 
$.post("/hotel/reserve/cancelReserve",{'id':$('#orderId').val(),'password':$('#password').val()},function(str){
	var res=eval('(' +str + ')')
	if(res.code!=0){
		alert(res.message)
		return;
	}else{
		res=res.object
		window.location.href="/hotel/reserve/getReserve?id="+$('#orderId').val()
	}
})
})
</c:if>

</script>
</html>